package com.crl.rcdp.sys.dao;

import com.crl.dao.BaseDao;
import com.crl.rcdp.sys.model.SysAppApi;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description:
 * @author: 孔垂云
 * @version: 1.0
 * @date: 2020/7/29 23:21
 */
@Repository
public class SysAppApiDao extends BaseDao<SysAppApi, SysAppApi> {


    /**
     * 新增app对应的api
     *
     * @param sysAppApi
     * @return
     */
    public int add(SysAppApi sysAppApi) {
        String sql = "insert into td_sys_app_api(appid,api_id) values(:appid,:apiId)";
        return insert(sql, sysAppApi);
    }

    /**
     * 按照appid删除
     *
     * @param appid
     * @return
     */
    public int deleteByAppid(String appid) {
        String sql = "delete from td_sys_app_api where appid=?";
        return delete(sql, appid);
    }

    /**
     * 根据appid获取api
     *
     * @param appid
     * @return
     */
    public List<SysAppApi> listByAppid(String appid) {
        String sql = "select t.*,(select url from td_sys_api where t.api_id=id) url from td_sys_app_api t where appid=?";
        return list(sql, appid);
    }
}
